package top.jandmla.shop.config.shiro;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;
import top.jandmla.shop.utils.md5.MD5Util;

public class MyCredentialsMatcher extends SimpleCredentialsMatcher {
    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        //获取登录密码
        String password = new String((char[]) token.getCredentials());
        //获取查询密码
        String sqlPassword = info.getCredentials().toString();
        //比较，并返回结果
        return MD5Util.verify(password,sqlPassword);
    }
}
